package com.hotkid.ceo.jetpack.myjetpackmvvm.base

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.viewbinding.ViewBinding

abstract class BaseFragment<VB :ViewBinding>:Fragment() {
    protected open var binding:VB?=null
    protected open val mBinding get() = binding!!

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding=getViewBinding()
        return binding?.root
    }

    abstract fun getViewBinding(): VB?

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        initialize()
    }

    open fun initialize(){}

    override fun onDestroy() {
        super.onDestroy()
        binding=null
    }
}